<?php include("../config.php"); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title><?php echo $sitename; ?> - Sysop: Remove Affiliate Data</title>
<meta name="description" content="<?php echo $sitename; ?> - Sysop: Remove Affiliate Data">
<meta name="keywords" content="free to try, software, shareware, freeware, developers, vendors, download, PAD">
<meta name="author" content="Andrey Aleksanyants, M.D.">
<meta name="copyright" content="easy HTools">
<meta http-equiv="imagetoolbar" content="no">
<link rel="stylesheet" type="text/css" href="../<?php echo $cssfile; ?>">
<link rel="shortcut icon" href="../favicon.ico">
<script language="javascript">
<!--
function formcheck() {
	if(document.aflremove.progid.value=="") {
		alert("You did not specify Program ID!");
		document.aflremove.progid.focus();
		return false;
	}
	return true;
}
//-->
</script>
</head>
<body>
<table class="tmain" align="center" width="90%" cellspacing="0" cellpadding="0">
<tr>
<td class="tmain">
<table class="tlogo" align="center" width="100%" cellspacing="0" cellpadding="4">
<tr>
<td align="right">
<p><a href="index.php">Home</a></p>
</td>
</tr>
</table>
</td>
</tr><tr>
<td class="tmain">
<br>
<table align="center" width="100%" border="0" cellspacing="0" cellpadding="1">
<tr valign="top">
<td class="tbody">
<h1><?php echo $sitename; ?> - Sysop: Remove Affiliate Data</h1>
<?php

// Requesting form data
$progid      = intval($_POST["progid"]);
$submit      = $_POST["submit"];

if(empty($submit)) {
	$progid      = $_GET["progid"];

	echo "<form name=\"aflremove\" action=\"" . $PHP_SELF . "\" method=\"post\" onsubmit=\"return formcheck()\">\n";
	echo "<table class=\"tvisible\" align=\"center\" width=\"440\" cellspacing=\"0\" cellpadding=\"4\">\n";
	echo "<tr>\n";
	echo "<th class=\"tablehead\" colspan=\"2\">Remove Affiliate Data</th>\n";
	echo "</tr><tr>\n";
	echo "<td class=\"tdark\"><label for=\"progid\"><p><b>Program ID:</b></p></label></td>\n";
	echo "<td><input type=\"text\" class=\"text\" name=\"progid\" size=\"10\" maxlength=\"10\" value=\"" . $progid . "\"> &nbsp;";
	echo "<input type=\"submit\" class=\"button\" name=\"submit\" value=\"  Remove  \"></td>\n";
	echo "</tr>\n";
	echo "</table>\n";
	echo "</form><br>\n";
}
else {
	$bad = "";
	if(empty($progid))      $bad.= "You did not specify Program ID!<br>\n";
	if($bad) {
		echo "<h2 class=\"red\">" . $bad . "</h2>";
		echo "<p>Go <a href=\"javascript:history.back()\">Back</a> and fill the form correctly.</p>\n";
		exit;
	}
	
	// Connecting to database
	if(!($link_id = mysql_connect($dbhost, $userid, $userpassword))) {
		die("<p><b>Error connecting to the database server:</b> " . mysql_error() . "</p>\n");
	}
	mysql_select_db($dbname);
	mysql_query("UPDATE paddata SET affiliate = '', affiliateid = '' WHERE progid = '$progid'", $link_id) or die("<p>Error removing Affiliate Data: " . mysql_error() . "</p>\n");
	echo "<p>Affiliate Data successfully removed. View details <a href=\"/details.php?progid=" . $progid . "\">here</a>.</p>\n";
	echo "<p>Go <a href=\"javascript:history.back()\">Back</a> to remove Affiliate Data for another software.</p>\n";
	echo "<p><a href=\"aflmanage.php\">Manage</a> your Affiliate Data.</p>\n";
	
	// Disconnecting from database
	mysql_close($link_id);
}
?>
<br>

</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>